<?php
namespace Common\Logic;
use Think\Controller;

/**
 * Description of UserLoginLogic.class控制器实例
 * 
 * @author songanwei
 * @date 2016-1-11
 */
class InterfaceServerLogic extends Controller {
    /**
     * 修改服务接口数据
     * @modify wenhui 2017-11-13
     * @param string $hotel 客栈id
     * @param string $serverId
     * @param string $url
     * @param string $token
     * @return array
     */
    public function saveInterfaceServer($hotelId, $hotel_usage = null, $hotel_enddate = null, $bk_hotel_opened = null, $bk_hotel_enddate = null) {
        // 调用RPC接口登录,修改服务接口数据
        Vendor('phpRPC.phprpc_client');
        $client = new \PHPRPC_Client(C('MANAGE_INTERFACESERVER_URL'));
        $client->setEncryptMode(3);

        $data = array(
            'flag' => 'uclbrt',
            'time' => time(),
            'hotel' => $hotelId,
        );

        if (!is_null($hotel_usage)) {
            $data['hotel_usage'] = $hotel_usage;
        }
        if (!is_null($hotel_enddate)) {
            $data['hotel_enddate'] = $hotel_enddate;
        }
        if (!is_null($bk_hotel_opened)) {
            $data['bk_hotel_opened'] = $bk_hotel_opened;
        }
        if (!is_null($bk_hotel_enddate)) {
            $data['bk_hotel_enddate'] = $bk_hotel_enddate;
        }

        $result = $client->saveInterfaceServer($data);

        if ($result['httpstatus'] == 200) {
            return true;
        }

        return false;
    }
}
